<template>
  <el-table :data="tableData" style="width: 100%" height="725px">
    <el-table-column prop="projectName" label="项目名" width="180"></el-table-column>
    <el-table-column prop="price" label="报价" width="180"></el-table-column>
    <el-table-column prop="timeLimit" label="工期"></el-table-column>
    <el-table-column prop="states" label="状态"></el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
          size="mini"
          @click="handleEdit(scope.$index, scope.row)">联系项目公司</el-button>

        <el-button
          size="mini"
          @click="handleEdittt(scope.$index, scope.row)">阶段性任务提交</el-button>

        <el-button v-if="scope.row.dingjin"
          size="mini"
          @click="handleEditt(scope.$index, scope.row)">请求支付定金</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>



<script>
  export default {
    data() {
      return {
        tableData: [
          {
            id:'',
            pid:'',
            price:'',
            projectName:'',
            timeLimit:'',
            projectDoc:'',
            states:'',
            dingjin:''
          }
        ]
      }
    },
    mounted: function(){
      var user= JSON.parse(window.sessionStorage.getItem("user"));
      var ff = this.$route.query.mallCode  //输入内容
      axios.post('/workroom/lookOrder',{
        wid : ff,
        id:ff
      }).then((response) => {
        console.log(ff)
        if( response.data != null){
          this.$notify({
            title: '成功',
            message: '成功',
            type: 'success',
            duration:2000
          });
          var e=response.data
          console.log(e)
          var data=[];
          var pp=0
          for(var c=0;c<e.length;c++) {
            var ee = e[c];
            if(ee.gid==0&&ee.tid==0){

            var obj = {}
            if(ee.states==0||ee.states==1||ee.states==2){
            obj.id=ee.id
            obj.pid=ee.pid
            obj.price=ee.price
            var nnn=ee.states
            if(nnn==0){
              obj.states="公司未付款"
            }else if(nnn==1){
              obj.states="公司付款但未支付定金"
              obj.dingjin=true
            }else{
              obj.states="定金已支付"
              obj.dingjin=false
            }


            obj.projectName=ee.projectName
            var ccc=ee.timeLimit
            var ggg=ccc.split("T")
            obj.timeLimit= ggg[0]
            obj.projectDoc=ee.projectDoc
            data[pp]=obj
            pp++}}
          }
          this. tableData=data
        }

        else{
          this.$notify({
            title: '失败',
            message: '错误',
            type: 'warning',
            duration:2000
          });
        }
      })

    },
    methods: {
      handleEdit(index, row) {

        // this.fid = this.$route.query.
        // this.tid = this.$route.query.tid
        // this.fname = this.$route.query.name
        var user= JSON.parse(window.sessionStorage.getItem("user"));

        var ee=user.id
       // var ff=row.pid
        this.$router.push({
          path: '/SendMassage',
          query: {
            tid:25,
            fid:26,
            name:"zzzzz"
          }
        })

      },
      handleEdittt(index, row) {

        // this.fid = this.$route.query.
        // this.tid = this.$route.query.tid
        // this.fname = this.$route.query.name
        // var user= JSON.parse(window.sessionStorage.getItem("user"));
        //
        // var ee=user.id
        var ff=row.id
        this.$router.push({
          path: '/ProjectStep',
          query: {
            id:ff,
          }
        })

      },
      handleEditt(index, row) {
        var ff=row.pid
        this.$router.push({
          path: '/SendMassage',
          query: {
            // mallCode:ff,
            // fid:
            // name:
          }
        })

      },


    }

  }
</script>



<style scoped>

</style>
